﻿using com.iot.core.annotation;
using com.iot.core.boot;
using com.iot.core.data;
using com.iot.core.data.entity;
using com.iot.core.infrastructure;
using com.iot.core.manager.auth;
using com.iot.core.manager.htcls;
using com.iot.ht.Controllers.htmenu.data;
using com.iot.ht.Controllers.htmenu.service; 
using com.iot.ht.Controllers.htuser.service;
using Microsoft.AspNetCore.Mvc; 

namespace com.iot.ht.Controllers.htmenu
{
    [ApiController]
    [Route("[controller]/[action]")]
    [Tag(Name = "菜单管理", Description = "")]
    public class HtMenuController : ControllerBase
    {
        private readonly IHtMenuService baseService;
        
        public HtMenuController(IHtMenuService p1)
        {
            baseService = p1;
        }


        [HttpPost]
        [Operation(Summary = "平台菜单", Description = "")]
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public async Task<List<TreeViewNode>> GetTree([FromBody] BaseQto mm)
        {
            var r = await AuthManager.Current.GetMenuByHtplatIdAsync(mm.Id);
            return r;
        }


        [HttpPost]
        [Operation(Summary = "菜单详情", Description = "")]         
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public async Task<HtMenuDto> DetailAsync(BaseQto qm)
        {
            return await baseService.DetailAsync(qm);
        }

        [HttpPost]
        [Operation(Summary = "添加菜单初始化", Description = "")]
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public HtMenuDto InsertInit(HtMenuInsertQto qm)
        {
            return   baseService.InsertInit(qm);
        }

        [HttpPost]
        [Operation(Summary = "添加菜单", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Insert(HtMenuDto qm)
        {
            return baseService.Insert(qm);
        }

        [HttpPost]
        [Operation(Summary = "修改菜单", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Update(HtMenuDto qm)
        {
            return baseService.Update(qm);
        }

        [HttpPost]
        [Operation(Summary = "删除菜单", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Delete(BaseQto qm)
        {
            return baseService.Delete(qm);
        }

         
    }
}
